# -*- encoding : utf-8 -*-
class ApplicationController < ActionController::Base
  protect_from_forgery
  
  before_filter :require_login, :init
  
  def require_login
    if params[:controller].index('admin')
      if session[:admin_user_id] == nil and params[:action] != 'login' and params[:action] != 'login_attempt'
        flash[:notice] = 'You must be logined to access this section'
        redirect_to :controller => 'admin/user', :action => 'login'
      end
    end
  end
  
  def init
    Time.zone = "Hanoi"
  end
end
